
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module divide</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>divide</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/media/sf_svns/occams/trunk/knife/divide.py">/media/sf_svns/occams/trunk/knife/divide.py</a></font></td></tr></table>
    <p><tt>Code&nbsp;to&nbsp;recursively&nbsp;partition&nbsp;one&nbsp;table&nbsp;into&nbsp;a&nbsp;tree&nbsp;of&nbsp;tables&nbsp;<br>
(a.k.a.&nbsp;dendograms).<br>
&nbsp;<br>
This&nbsp;code&nbsp;is&nbsp;part&nbsp;of&nbsp;KNIFE:&nbsp;cropping&nbsp;complexity,&nbsp;culling&nbsp;confusion,&nbsp;<br>
and&nbsp;cutting&nbsp;the&nbsp;crap&nbsp;since&nbsp;2012<br>
&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.----------------._________________<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|=()=========---&nbsp;&nbsp;\-----------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`\&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;jgs&nbsp;&nbsp;\_________________/^^^^^^^^^^^^^^^^^^<br>
&nbsp;<br>
(c)&nbsp;2012,&nbsp;Tim&nbsp;Menzies,&nbsp;tim@menzies.us,&nbsp;LGPL&nbsp;v3.0</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="math.html">math</a><br>
</td><td width="25%" valign=top><a href="random.html">random</a><br>
</td><td width="25%" valign=top><a href="re.html">re</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="divide.html#Divide">Divide</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Divide">class <strong>Divide</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>A&nbsp;<a href="#Divide">Divide</a>&nbsp;is&nbsp;an&nbsp;Table&nbsp;with&nbsp;zero&nbsp;or&nbsp;more&nbsp;sub-tables.&nbsp;Kids&nbsp;are<br>
generated&nbsp;via&nbsp;the&nbsp;max-distance&nbsp;heuristic;&nbsp;i.e.&nbsp;(1)&nbsp;project&nbsp;all<br>
points&nbsp;onto&nbsp;a&nbsp;line&nbsp;drawn&nbsp;between&nbsp;the&nbsp;two&nbsp;most&nbsp;distant&nbsp;points&nbsp;<br>
in&nbsp;the&nbsp;table;&nbsp;(2)&nbsp;split&nbsp;the&nbsp;data&nbsp;at&nbsp;the&nbsp;median&nbsp;point&nbsp;of&nbsp;that&nbsp;line;<br>
(3)&nbsp;recurse&nbsp;on&nbsp;the&nbsp;two&nbsp;halves.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Divide-__init__"><strong>__init__</strong></a>(self, table)</dt><dd><tt>The&nbsp;two&nbsp;most&nbsp;distance&nbsp;points&nbsp;are&nbsp;'west'&nbsp;and&nbsp;'east'&nbsp;and&nbsp;have<br>
distance&nbsp;'c'&nbsp;between&nbsp;them.&nbsp;The&nbsp;projection&nbsp;of&nbsp;all&nbsp;points&nbsp;between<br>
is&nbsp;computed&nbsp;and&nbsp;caches&nbsp;in&nbsp;'xs'.</tt></dd></dl>

<dl><dt><a name="Divide-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Pretty&nbsp;print&nbsp;for&nbsp;this&nbsp;table.</tt></dd></dl>

<dl><dt><a name="Divide-expected"><strong>expected</strong></a>(self)</dt><dd><tt>Ask&nbsp;the&nbsp;class&nbsp;what&nbsp;value&nbsp;it&nbsp;expects&nbsp;over&nbsp;this&nbsp;table.</tt></dd></dl>

<dl><dt><a name="Divide-hprint"><strong>hprint</strong></a>(self, level<font color="#909090">=0</font>)</dt><dd><tt>Pretty&nbsp;print&nbsp;for&nbsp;a&nbsp;tree&nbsp;of&nbsp;tables.</tt></dd></dl>

<dl><dt><a name="Divide-last"><strong>last</strong></a>(self)</dt><dd><tt>Returns&nbsp;max&nbsp;index&nbsp;of&nbsp;data.</tt></dd></dl>

<dl><dt><a name="Divide-nearest"><strong>nearest</strong></a>(self, cells)</dt><dd><tt>Explore&nbsp;my&nbsp;kids&nbsp;looking&nbsp;for&nbsp;the&nbsp;table&nbsp;closest&nbsp;to&nbsp;'cells'&nbsp;<br>
(and&nbsp;'cells'&nbsp;is&nbsp;a&nbsp;list&nbsp;of&nbsp;strings&nbsp;or&nbsp;floats)</tt></dd></dl>

<dl><dt><a name="Divide-parts"><strong>parts</strong></a>(self, enough<font color="#909090">=4</font>)</dt><dd><tt>Splits&nbsp;the&nbsp;data&nbsp;on&nbsp;the&nbsp;median&nbsp;point&nbsp;of&nbsp;the&nbsp;projections.</tt></dd></dl>

<dl><dt><a name="Divide-projections"><strong>projections</strong></a>(self)</dt><dd><tt>Returns&nbsp;all&nbsp;the&nbsp;projections,&nbsp;sorted.</tt></dd></dl>

<dl><dt><a name="Divide-westeast"><strong>westeast</strong></a>(self)</dt><dd><tt>Finds&nbsp;the&nbsp;two&nbsp;most&nbsp;distant&nbsp;points.&nbsp;If&nbsp;'fast',&nbsp;it<br>
uses&nbsp;the&nbsp;linear-time&nbsp;FastMap&nbsp;trick&nbsp;(pick&nbsp;anything,&nbsp;'west'&nbsp;is<br>
furthest&nbsp;from&nbsp;that,&nbsp;and&nbsp;'east'&nbsp;is&nbsp;furthest&nbsp;from&nbsp;west).&nbsp;If<br>
'slow',&nbsp;it&nbsp;does&nbsp;and&nbsp;all&nbsp;pairs&nbsp;comparison.</tt></dd></dl>

<dl><dt><a name="Divide-wiggle"><strong>wiggle</strong></a>(self)</dt><dd><tt>Ask&nbsp;the&nbsp;class&nbsp;what&nbsp;wiggle&nbsp;it&nbsp;expects&nbsp;in&nbsp;the&nbsp;expected&nbsp;value.</tt></dd></dl>

<dl><dt><a name="Divide-x"><strong>x</strong></a>(self, r)</dt><dd><tt>Projects&nbsp;row&nbsp;with&nbsp;index&nbsp;'r'&nbsp;onto&nbsp;the&nbsp;west-east&nbsp;line.<br>
For&nbsp;effeciency's&nbsp;sake,&nbsp;this&nbsp;result&nbsp;is&nbsp;cached&nbsp;in&nbsp;'xs'.</tt></dd></dl>

<dl><dt><a name="Divide-x0"><strong>x0</strong></a>(self, a, b)</dt><dd><tt>Primitive&nbsp;for&nbsp;projecting&nbsp;a&nbsp;line&nbsp;with&nbsp;distance&nbsp;'a'&nbsp;and&nbsp;'b'<br>
to&nbsp;'west'&nbsp;and&nbsp;'east'&nbsp;onto&nbsp;the&nbsp;west-east&nbsp;line.</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-idea"><strong>idea</strong></a>(divisor, level<font color="#909090">=0</font>, enough<font color="#909090">=0</font>, ripe<font color="#909090">=0.5</font>, min<font color="#909090">=4</font>)</dt><dd><tt>Top&nbsp;level&nbsp;driver&nbsp;for&nbsp;the&nbsp;recursive&nbsp;division.</tt></dd></dl>
</td></tr></table>
</body></html>